﻿// <copyright file="MetadataStore.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2009-06-04</date>
// <summary>MetadataStore class definition</summary>

namespace Microsoft.WebAnalytics.Behaviors.Design
{
    using System.ComponentModel;
    using System.Windows.Interactivity;
    using Microsoft.WebAnalytics.Behaviors;
    using Microsoft.WebAnalytics.Design.Editors;
    using Microsoft.Windows.Design;
    using Microsoft.Windows.Design.Metadata;
    using Microsoft.Windows.Design.PropertyEditing;

    /// <summary>
    /// Design-time metadata store
    /// </summary>
    public class MetadataStore : IProvideAttributeTable
    {
        #region IProvideAttributeTable Members

        /// <summary>
        /// Gets the attribute table for metadata about the Microsoft.WebAnalytics assembly
        /// </summary>
        public AttributeTable AttributeTable
        {
            get
            {
                var builder = new AttributeTableBuilder();

                builder.AddCustomAttributes(
                    typeof(ConsoleAnalytics),
                    new DescriptionAttribute(Properties.Resources.StatusAnalyticsDescription),
                    new ToolboxCategoryAttribute(Properties.Resources.Analytics));

                builder.AddCustomAttributes(
                    typeof(ConsoleAnalytics),
                    "Events",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(ServiceOrientedAnalytics),
                    new DescriptionAttribute(Properties.Resources.ServiceOrientedAnalyticsDescription),
                    new EditorAttribute(typeof(AnalyticsCategoryEditor), typeof(AnalyticsCategoryEditor)),
                    new ToolboxCategoryAttribute(Properties.Resources.Analytics));

                builder.AddCustomAttributes(
                    typeof(ServiceOrientedAnalytics),
                    "Endpoint",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.EndpointDescription));

                builder.AddCustomAttributes(
                    typeof(ServiceOrientedAnalytics),
                    "Method",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.EndpointDescription));

                builder.AddCustomAttributes(
                    typeof(ServiceOrientedAnalytics),
                    "Dispatch",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(ServiceOrientedAnalytics),
                    "AccountId",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.AccountIdDescription),
                    new DisplayNameAttribute(Properties.Resources.AccountId));

                builder.AddCustomAttributes(
                    typeof(ServiceOrientedAnalytics),
                    "Version",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.VersionDescription));

                builder.AddCustomAttributes(
                    typeof(ServiceOrientedAnalytics),
                    "Events",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(ABTesting),
                    "ABTestingStateName",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(ABTesting),
                    "SaveTestingState",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(ABTesting),
                    new DescriptionAttribute(Properties.Resources.ABTestingDescription),
                    new DisplayNameAttribute(Properties.Resources.ABTesting),
                    new EditorAttribute(typeof(AnalyticsCategoryEditor), typeof(AnalyticsCategoryEditor)),
                    new ToolboxCategoryAttribute(Properties.Resources.Analytics));

                builder.AddCustomAttributes(
                    typeof(ABTesting),
                    "DefaultState",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new CustomPropertyValueEditorAttribute(CustomPropertyValueEditor.StateName),
                    new DescriptionAttribute(Properties.Resources.DefaultStateDescription),
                    new DisplayNameAttribute(Properties.Resources.DefaultState));

                builder.AddCustomAttributes(
                    typeof(ABTesting),
                    "StateGroup",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.StateGroupDescription),
                    new DisplayNameAttribute(Properties.Resources.StateGroup));

                builder.AddCustomAttributes(
                    typeof(ABTesting),
                    "PercentageOfTraffic",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.PercentageOfTrafficDescription),
                    new DisplayNameAttribute(Properties.Resources.PercentageOfTraffic),
                    new NumberFormatAttribute(Properties.Resources.PercentageOfTrafficNumberFormat, 2, 100),
                    new NumberIncrementsAttribute(0.01, 0.05, 0.1),
                    new NumberRangesAttribute(new double?(0.0), new double?(0.0), 1.0, 1.0, null));

                builder.AddCustomAttributes(
                    typeof(TrackAction),
                    new DescriptionAttribute(Properties.Resources.TrackActionDescription),
                    new EditorAttribute(typeof(AnalyticsCategoryEditor), typeof(AnalyticsCategoryEditor)),
                    new ToolboxCategoryAttribute(Properties.Resources.Analytics));

                builder.AddCustomAttributes(
                    typeof(TrackAction),
                    "Value",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.ValueDescription));

                builder.AddCustomAttributes(
                    typeof(TrackAction),
                    "Category",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.CategoryDescription));

                builder.AddCustomAttributes(
                    typeof(TrackAction),
                    "Handlers",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(TrackAction),
                    "Log",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(TrackAction),
                    "CustomProperties",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.CustomPropertiesDescription),
                    new DisplayNameAttribute(Properties.Resources.CustomProperties));

                builder.AddCustomAttributes(
                    typeof(TrackForm),
                    new ToolboxCategoryAttribute(Properties.Resources.Analytics),
                    new EditorAttribute(typeof(AnalyticsCategoryEditor), typeof(AnalyticsCategoryEditor)),
                    new DescriptionAttribute(Properties.Resources.TrackFormDescription));

                builder.AddCustomAttributes(
                    typeof(TrackFormControl),
                    new ToolboxCategoryAttribute(Properties.Resources.Analytics),
                    new EditorAttribute(typeof(AnalyticsCategoryEditor), typeof(AnalyticsCategoryEditor)),
                    new DescriptionAttribute(Properties.Resources.TrackFormControlDescription));

                builder.AddCustomAttributes(
                    typeof(TrackForm),
                    "CustomProperties",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.CustomPropertiesDescription),
                    new DisplayNameAttribute(Properties.Resources.CustomProperties));

                builder.AddCustomAttributes(
                    typeof(TrackForm),
                    "Category",
                    new CategoryAttribute(Properties.Resources.Analytics));

                builder.AddCustomAttributes(
                    typeof(TrackForm),
                    "FormHandlers",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(TrackForm),
                    "Handlers",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(TrackForm),
                    "Log",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(TrackForm),
                    "Value",
                    new CategoryAttribute(Properties.Resources.Analytics));

                builder.AddCustomAttributes(
                    typeof(TrackTouch),
                    new DescriptionAttribute(Properties.Resources.TrackTouchDescription),
                    new EditorAttribute(typeof(AnalyticsCategoryEditor), typeof(AnalyticsCategoryEditor)),
                    new ToolboxCategoryAttribute(Properties.Resources.Analytics));

                builder.AddCustomAttributes(
                    typeof(TrackTouch),
                    "Log",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(Pulse),
                    new DescriptionAttribute(Properties.Resources.PulseDescription),
                    new EditorAttribute(typeof(AnalyticsCategoryEditor), typeof(AnalyticsCategoryEditor)),
                    new ToolboxCategoryAttribute(Properties.Resources.Analytics));

                builder.AddCustomAttributes(
                    typeof(Pulse),
                    "Log",
                    BrowsableAttribute.No);

                builder.AddCustomAttributes(
                    typeof(Pulse),
                    "Interval",
                    new CategoryAttribute(Properties.Resources.Analytics),
                    new DescriptionAttribute(Properties.Resources.IntervalDescription));

                return builder.CreateTable();
            }
        }

        #endregion
    }
}
